using System;
using System.Collections.Generic;
using System.Text;

using NUnit.Framework;

using NSimpleDB.Service.Contract;

namespace test.Service.VistaDb.Whitebox
{
    [TestFixture]
    public class test_Compile_Attributes_to_Item_Select_Sql_Where
    {
        [Test]
        public void test()
        {
            NSimpleDB.Service.VistaDb.Managers.ItemManager im;
            im = new NSimpleDB.Service.VistaDb.Managers.ItemManager(null, null);

            string where;

            where = im.CompileAttributesToItemSelectSqlWhere("iii", new ISimpleDBAttribute[] { }, false);
            Assert.AreEqual("itemName='iii'", where);

            where = im.CompileAttributesToItemSelectSqlWhere("iii", new ISimpleDBAttribute[] { new SimpleDBAttribute("a") }, false);
            Assert.AreEqual("itemName='iii' and ((attributeName='a'))", where);

            where = im.CompileAttributesToItemSelectSqlWhere("iii", new ISimpleDBAttribute[] { new SimpleDBAttribute("a"), new SimpleDBAttribute("b") }, false);
            Assert.AreEqual("itemName='iii' and ((attributeName='a') or (attributeName='b'))", where);

            where = im.CompileAttributesToItemSelectSqlWhere("iii", new ISimpleDBAttribute[] { new SimpleDBAttribute("a", "av"), new SimpleDBAttribute("b", "bv") }, true);
            Assert.AreEqual("itemName='iii' and ((attributeName='a' and attributeValue='av') or (attributeName='b' and attributeValue='bv'))", where);
        }
    }
}
